package br.rc.unesp.tcc.resources;

/**
 * http://dafionsoftware.blogspot.com.br/2011/05/how-to-call-jersey-restful-service-from.html
 */

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import br.rc.unesp.tcc.business.services.StudentServices;
import br.rc.unesp.tcc.business.services.StudentServicesImpl;
import br.rc.unesp.tcc.business.to.StudentListTO;
import br.rc.unesp.tcc.model.bean.Student;


@Path("/student")
public class StudentResource {

	// @Autowired
	StudentServices studentServices = new StudentServicesImpl();

	@GET
	@Path("{id:[0-9]+}")
	@Produces({ MediaType.APPLICATION_JSON })
	public Response findById(@PathParam("id") final int id) {

		System.out.println(id);

		Student student = studentServices.findById(id);

		return Response.ok(student).build();
	}

	@GET
	@Produces({ MediaType.APPLICATION_JSON })
	public Response findAll() {
		StudentListTO studentList = studentServices.findAll();
		
		return Response.ok(studentList).build();
	}
}
